const App = {
    mixins: [Query],//配置文件，路径/utils/mixins.js
    data() {
        return {
            page: {
                value1: '',
                value2: '',
                cityValue: [],
                PageNumber: 1, //页码
                RowAmount: 10,
                Condition: window.btoa(unescape(encodeURIComponent("%%,%%,%%"))),
                ExtensionCondition: window.btoa(unescape(encodeURIComponent(" and  natural_resources_management.Village_SerialNumber in (" + getCookie('village') + ")"))),
            },
            Natural_Resource_Usage: [],
            isType: '0',//0:种植 1:畜牧 2:渔业
            // treeData:[]
        }
    },
    mounted() {
        let ls_URL = window.location.href;
        this.isType = getQueryObject(ls_URL, "type") ? getQueryObject(ls_URL, "type") : '0';// 获取 nodeKey 参数
    },
    methods: {
        Treedata() {
            // $.ajax({
            //     headers: requestHeaders(),
            //     url: `${mh}/clientOperation/getDistrictTree`,
            //     type: "GET",
            //     data: {
            //         DistrictCode: '232723'
            //     },
            //     success: (data) => {
            //         this.treeData = data; // 直接使用 this
            //     },
            //     complete: (XMLHttpRequest) => {
            //         requestPretreatment(XMLHttpRequest);
            //     },
            //     dataType: "json",
            // });

            $.ajax({
                headers: requestHeaders(),
                url: `${mh}/permissionsTree/getDistrictTreeByPermissions`,
                type: "GET",
                data: {
                    DistrictCode: getCookie('village'),

                },
                success: (data) => {
                    this.treeData = data; // 直接使用 this
                },
                complete: (XMLHttpRequest) => {
                    requestPretreatment(XMLHttpRequest);
                },
                dataType: "json",
            });

            // $.ajax({
            //     headers: requestHeaders(),
            //     url: `${mh}/generalBusiness/generalQueryForObtainingTrees`,
            //     type: "GET",
            //     data: {
            //         TableName: 'natural_resources_usage',
            //         NodeCode: '',
            //     },
            //     success: (data) => {
            //         data.forEach(item => {
            //             item.children.forEach(it => {
            //                 it.Natural_Resource_Usage_Name = it.Natural_Resource_Usage_Name + (it.Natural_Resource_Type ? ' - ' + it.Natural_Resource_Type : '')
            //             })
            //         })
            //         this.Natural_Resource_Usage = data; // 直接使用 this
            //     },
            //     complete: (XMLHttpRequest) => {
            //         requestPretreatment(XMLHttpRequest);
            //     },
            //     dataType: "json",
            // });
        },
        check() {
            this.page.Condition = window.btoa(unescape(encodeURIComponent("%" + this.page.value1 + "%,%%,%" + (this.page.cityValue[1] ||'') + "%")));
            // this.page.Condition = window.btoa(unescape(encodeURIComponent("%" + this.page.value1 + "%,%%,%" + this.page.cityValue[1] + "%")));
            this.postgetList(this.page)
        },
        //树的点击筛选事件
        handleNodeClick(data, node) {
            this.page.Condition = window.btoa(unescape(encodeURIComponent("%" + this.page.value1 + "%," + data.ProvinceNumber + "%,%" + (this.page.cityValue.length == 2 ? this.page.cityValue[1] : '') + "%")));
            this.postgetList(this.page);
        },
        handleShow(row) {
            window.location.href = './show.html?Land_SerialNumber=' + row.Land_SerialNumber + '&type=' + this.isType
        },
        personalAdd() {
            window.location.href = "./add.html?action=Add&type=" + this.isType;
        },
        //编辑按钮
        handleEdit(row) {
            let { primary_key } = JSON.parse(document.getElementById("table").getAttribute("data-options"));
            window.location.href = "./add.html?action=Modify&nodeKey=" + row[primary_key] + "&type=" + this.isType;
        },
    },
};

const { createApp } = Vue;
const app = createApp(App);
//这种方式是引入全部图标，无需单个引入
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
    app.component(key, component);
}
const ElMessage = ElementPlus.ElMessage;
app.use(ElementPlus, { locale: zhCn });
app.mount("#app");
